package cn.yr.blog.controller.app;


import cn.hutool.core.util.ObjectUtil;
import cn.yr.blog.service.VersionService;
import cn.yr.common.core.domain.entity.YrVersion;
import cn.yr.common.core.domain.vo.PageVo;
import cn.yr.common.exception.ret.Ret;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import io.swagger.annotations.Api;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * @author lang 1102076808@qq.com
 * @Description  版本记录
 * @Date 15:50 2021/5/23
 **/
@Api(tags = "app版本管理")
@RequestMapping("/app/version")
@RestController
public class AppVersionController {

    @Autowired
    private VersionService versionService;

    /**
     * 分页列表
     */
    @RequestMapping("/page")
    public Ret page(@RequestBody PageVo<YrVersion> pageVo){
        QueryWrapper<YrVersion> wrapper = new QueryWrapper<>();
        wrapper.like(ObjectUtil.isNotEmpty(pageVo.getParams().get("tag")),"tag",pageVo.getParams().get("tag"));
        wrapper.like(ObjectUtil.isNotEmpty(pageVo.getParams().get("description")),"description",pageVo.getParams().get("description"));
        wrapper.orderByDesc("tag");
        PageVo<YrVersion> pageYrVersion = versionService.page(pageVo,wrapper);
        return Ret.success(pageYrVersion);
    }
}
